package com.ct.boot.launch.model;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.List;
import java.util.Map;

/**
 * @Auther: Charles chen
 * @Date: 2020/7/15 11:32
 * @Description:
 */
@Data
@Configuration
@PropertySource(value = "classpath:employee.properties",encoding = "utf-8")
//@Value(value = "${employee.name}") 普通获取配置文件属性
public class Employee {
    //spEl表达式
    @Value(value = "#{'${employee.name}'.split('\\|')}")
    private List<String> employeeName;
    @Value(value = "#{'${employee.name}'.split('\\|')[0]}")
    private String firstName;
    @Value(value = "#{${employee.age}}")
//    @Value(value = "#{${employee.age}['two']}")
    private Map<String, Integer> employeeAge;
//    @Value(value = "#{${employee.age}.two}")
    @Value(value = "#{${employee.age}['two']}")
    private String employeeAgeTwo;
    @Value(value = "#{${employee.age}['five'] ?: 31}")
    private Integer ageWithDefaultValue;
    @Value("#{systemProperties['java.home']}")
    private String javaHome;
    @Value("#{systemProperties['user.dir']}")
    private String userDir;
}
